import Vue from 'vue'
import VueRouter from 'vue-router'
import Layout from '@/views/Layout'
import Home from '@/views/Home'
import Info from '@/views/Info'
import Search from '@/views/Search'
import User from '@/views/User'
import Login from '@/views/Login'
import Register from '@/views/Register'
import City from '@/views/City'
import Collect from '@/views/Collect'
import Rent from '@/views/Rent'
import RentAdd from '@/views/RentAdd'
import RentSearch from '@/views/RentSearch'
import Detail from '@/views/Detail'
Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    component: Layout,
    redirect: '/home',
    children: [
      {
        path: '/home',
        component: Home
      },
      {
        path: '/home/search',
        component: Search
      },
      {
        path: '/home/info',
        component: Info
      },
      {
        path: '/home/user',
        component: User
      }
    ]
  },
  {
    path: '/login',
    component: Login
  },
  {
    path: '/register',
    component: Register
  },
  {
    path: '/city',
    component: City
  },
  {
    path: '/collect',
    component: Collect
  },
  {
    path: '/rent',
    component: Rent
  },
  {
    path: '/rent/add',
    component: RentAdd
  },
  {
    path: '/rent/search',
    component: RentSearch
  },
  {
    path: '/detail/:id',
    component: Detail,
    props: true
  }
]

const router = new VueRouter({
  routes
})

export default router
